package ar.edu.itba.pod.legajo48013;

import java.net.UnknownHostException;
import java.rmi.RemoteException;

import org.joda.time.Duration;

import ar.edu.itba.pod.agent.market.Consumer;
import ar.edu.itba.pod.agent.market.Market;
import ar.edu.itba.pod.agent.market.Producer;
import ar.edu.itba.pod.agent.market.Resource;
import ar.edu.itba.pod.legajo48013.host.Host;
import ar.edu.itba.pod.time.TimeMapper;
import ar.edu.itba.pod.time.TimeMappers;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws UnknownHostException, RemoteException
    {
    	Host host = new Host(1098, "cluster1");

		host.getCluster().createGroup();
		
		TimeMapper timeMapper = TimeMappers.oneSecondEach(Duration.standardHours(6));
		DistributedSimulation node = new DistributedSimulation(timeMapper, host.getDispatcher(), host.getNode().id());
		
//		Resource gold = new Resource("Mineral", "Gold");
//		Resource steel = new Resource("Alloy", "Steel");
		
//		node.add(new Producer("gold mine", gold, Duration.standardDays(1), 1));
//		node.add(new Market("gold market", gold));
//		node.add(new Consumer("steel consumer", steel, Duration.standardDays(2), 4));
//		node.add(new Consumer("gold consumer", gold, Duration.standardDays(2), 4));
		
		System.out.println("Starting ...");
		try {
			node.startAndWait(Duration.standardMinutes(10));
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
    	
    }
}
